#include<bits/stdc++.h>
using namespace std;
const int N = 5010;
const int MOD = 998244353;
int a[N];
vector<int> Fcur;
int delta[N];
vector<int> operator+(const vector<int> &v1,const vector<int> &v2){
    vector<int> res(v1);
    if(v2.size() > v1.size()){
        res.resize(v2.size());
    }
    for(int i = 0;i < v2.size();i++){
        res[i] = (res[i] + v2[i])%MOD;
    }
    return res;
}
int qpow(int x,int p){
    int res = 1;
    while(p){
        if(p & 1){
            res = 1ll*res*x%MOD;
        }
        x = 1ll*x*x%MOD;
        p >>= 1;
    }
    return res;
}
int bpos,bval;
vector<int> bfunc;
void calc(int x){
    int res = 0;
    for(int j = 0;j < Fcur.size();j++){
        res = (res + 1ll*Fcur[j]*a[x - 1 - j]%MOD)%MOD;
    }
    if((a[x] - res + MOD)%MOD == 0){
        return;
    }else if(Fcur.size()){
        delta[x] = (a[x] - res + MOD)%MOD;
        int ap = bpos;
        vector<int> df(x - ap + bfunc.size(),0);
        int attb = 1ll*delta[x]*qpow(delta[ap],MOD - 2)%MOD;
        df[x - ap - 1] = attb;
        for(int j = 0;j < bfunc.size();j++){
            df[x - ap + j] = 1ll*((MOD - attb)%MOD)*bfunc[j]%MOD;
        }
        if(-x + Fcur.size() < bval){
            bval = -x + Fcur.size();
            bpos = x;
            bfunc = Fcur;
        }
        Fcur = Fcur + df;
    }else{
        bval = -x;
        bpos = x;
        bfunc = Fcur;
        Fcur = vector<int>(x,0);
        delta[x] = a[x];
    }
}
int main(){
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
    }
    for(int i = 1;i<=n;i++){
        calc(i);
    }
    cout<<Fcur.size()<<'\n';
    for(int i = 0;i < Fcur.size();i++){
        cout<<Fcur[i]<<' ';
    }
    cout<<'\n';
}